package com.cea.papyrustest.uml.createcommand;

import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Enumeration;

import com.cea.papyrus.core.commands.UMLElementCreateCommand;

/**
 * Test class for {@link Enumeration} creation command
 * @author Remi Schnekenburger
 */
public class EnumerationCreateCommandTest extends PapyrusCommandTest{

	/**
	 * Default constructor
	 * @param name the name oif the test case
	 */
	public EnumerationCreateCommandTest(String name) {
		super(name);	
	}

	@Override
	protected void setUp() throws Exception {
		super.setUp();
		papyrusCommand= new UMLElementCreateCommand(org.eclipse.uml2.uml.Enumeration.class,model);
	}

	/* (non-Javadoc)
	 * @see com.cea.papyrustest.PapyrusCommandTest#testExecute()
	 */
	@Override
	public void testExecute() {
		stack.execute(papyrusCommand);
		Element clazz=model.getPackagedElement("Enumeration_0");
		assertNotNull("the enumeration is created",clazz);
		assertTrue("this is not a enumeration",((clazz)instanceof Enumeration));
		
		// undo
		stack.undo();
		assertNull("the enumeration exist!",model.getPackagedElement("Enumeration_0"));
		
		// redo
		stack.redo();
		clazz=model.getPackagedElement("Enumeration_0");
		assertNotNull("the enumeration is not re-created",clazz);
		assertTrue("this is not a enumeration",((clazz)instanceof Enumeration));
	}
}
